package org.imdm.portal.loadchecker.telnet;

public abstract class Command {

  protected TelnetClientAdvance telnet;

  public Command(TelnetClientAdvance telnet) {
    this.telnet = telnet;
  }

  private void connect() throws TelnetException{
	  if(!telnet.hasLogin()){
        telnet.connect();
      }
  }
  public String sendCommand(String cmd) throws TelnetException{
    connect();
    return telnet.sendCommand(cmd);
  }

  public String sendCommand(String cmd,String prompt)throws TelnetException{
    connect();
    return telnet.sendCommand(cmd,prompt);
  }


  public abstract String execute()  throws TelnetException;

  public void stop(){
   telnet.disconnect();
  }
}
